package org.snake.spring.framework.webmvc.servlet;

import java.lang.reflect.Method;
import java.util.regex.Pattern;

/**
 * 1.此类是为了缓存url和Method之间的对应关系
 * 2.controller是自定义的，为了更好的找到对应的controller，Spring源码中并无此设计
 *
 * @author Ray
 */
public class RAYHandlerMapping
{

    /**
     * 保存url，此URL处理为一个正则表达式
     */
    private Pattern pattern;

    /**
     * 保存url对应的Method
     */
    private Method method;

    /**
     * 保存Method对应的Controller
     */
    private Object controller;

    /**
     * 构造函数
     *
     * @param pattern    请求的URL
     * @param controller URL对应的Controller对象
     * @param method     URL对应的Controller对象中的方法
     */
    public RAYHandlerMapping(Pattern pattern, Object controller, Method method)
    {

        this.pattern = pattern;
        this.controller = controller;
        this.method = method;
    }

    public Pattern getPattern()
    {

        return pattern;
    }

    public void setPattern(Pattern pattern)
    {

        this.pattern = pattern;
    }

    public Method getMethod()
    {

        return method;
    }

    public void setMethod(Method method)
    {

        this.method = method;
    }

    public Object getController()
    {

        return controller;
    }

    public void setController(Object controller)
    {

        this.controller = controller;
    }

}
